/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * OpcoesMenu.java
 *
 * Created on 16/Jan/2012, 12:17:06
 */
package menus;

import desint.JanelaPrincipal;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import popup.AtivEdit;
import popup.AtivNovo;
import popup.AvaliacaoNovo;
import popup.EspacoEdit;
import popup.EspacoNovo;
import popup.ExercicioEdit;
import popup.ExercicioNovo;
import popup.PlanoTreinoEdit;
import popup.PlanoTreinoNovo;
import popup.UtilEdit;
import popup.UtilNovo;

/**
 *
 * @author Leonardo Lino
 */
public class OpcoesMenu extends javax.swing.JPanel {
    
    JanelaPrincipal jp;

    /** Creates new form OpcoesMenu */
    public OpcoesMenu() {
        initComponents();
        
    }
    
    public void setJanelaPrincipal(JanelaPrincipal jp){
        this.jp = jp;
        chkEstado();
    }

   
   
    public void setTexto(String s){
        texto.setText(s);
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        bNovo = new javax.swing.JButton();
        bEdit = new javax.swing.JButton();
        apagar = new javax.swing.JButton();
        texto = new javax.swing.JLabel();

        bNovo.setText("Novo");
        bNovo.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                bNovoMouseClicked(evt);
            }
        });

        bEdit.setText("Editar");
        bEdit.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                bEditMouseClicked(evt);
            }
        });

        apagar.setText("Apagar");
        apagar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                apagarMouseClicked(evt);
            }
        });

        texto.setFont(new java.awt.Font("Tahoma", 1, 18));
        texto.setText("Utilizadores");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(bNovo)
                        .addGap(18, 18, 18)
                        .addComponent(bEdit)
                        .addGap(18, 18, 18)
                        .addComponent(apagar))
                    .addComponent(texto))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bNovo, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(bEdit, javax.swing.GroupLayout.DEFAULT_SIZE, 44, Short.MAX_VALUE)
                    .addComponent(apagar, javax.swing.GroupLayout.DEFAULT_SIZE, 44, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addComponent(texto)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    
    private void chkEstado(){
        
        
    }
    
    
    private void bNovoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_bNovoMouseClicked
       
        JDialog novo = null;
        
        if (jp.getMenu() == JanelaPrincipal.MENU_UTILIZADOR) {
            novo = new UtilNovo(null, true);
        }
        
        
        if (jp.getMenu() == JanelaPrincipal.MENU_ATIVIDADE) {
            novo = new AtivNovo(null, true);
        }
        
        if (jp.getMenu() == JanelaPrincipal.MENU_ESPACO) {
            novo = new EspacoNovo(null, true);
        }
        
        if (jp.getMenu() == JanelaPrincipal.MENU_EXERCICIO) {
            novo = new ExercicioNovo(null, true);
        }
        
        if (jp.getMenu() == JanelaPrincipal.MENU_PLANO) {
            novo = new PlanoTreinoNovo(null, true);
        }
        
        if (jp.getMenu() == JanelaPrincipal.MENU_AVALIACAO) {
            novo = new AvaliacaoNovo(null, true);
        }
        
        if (jp.getMenu() != JanelaPrincipal.MENU_CONTROL 
                && jp.getMenu() != JanelaPrincipal.MENU_AGENDA_SOCIO
                && jp.getMenu() != JanelaPrincipal.MENU_PLANO_SOCIO
                && jp.getMenu() != JanelaPrincipal.MENU_AVALIACAO_SOCIO
                && jp.getMenu() != JanelaPrincipal.MENU_AGENDA){
         novo.setLocation(100, 100);
         novo.setVisible(true);
        }
        
    }//GEN-LAST:event_bNovoMouseClicked

    private void bEditMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_bEditMouseClicked
       JDialog novo = null;
       
        if (jp.getMenu() == JanelaPrincipal.MENU_UTILIZADOR) {
            novo = new UtilEdit(null, true);   
        }
       
        if (jp.getMenu() == JanelaPrincipal.MENU_ATIVIDADE) {
            novo = new AtivEdit(null, true);
        }
        
        if (jp.getMenu() == JanelaPrincipal.MENU_EXERCICIO) {
            novo = new ExercicioEdit(null, true);
        }
        
        if (jp.getMenu() == JanelaPrincipal.MENU_PLANO) {
            novo = new PlanoTreinoEdit(null, true);
        }
        
        if (jp.getMenu() == JanelaPrincipal.MENU_ESPACO) {
            novo = new EspacoEdit(null, true);
        }
        
        
        if (jp.getMenu() != JanelaPrincipal.MENU_CONTROL 
                && jp.getMenu() != JanelaPrincipal.MENU_AGENDA 
                && jp.getMenu() != JanelaPrincipal.MENU_AGENDA_SOCIO
                && jp.getMenu() != JanelaPrincipal.MENU_PLANO_SOCIO
                && jp.getMenu() != JanelaPrincipal.MENU_AVALIACAO_SOCIO
                && jp.getMenu() != JanelaPrincipal.MENU_AVALIACAO){
         novo.setLocation(100, 100);
         novo.setVisible(true);
        }
    }//GEN-LAST:event_bEditMouseClicked

    private void apagarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_apagarMouseClicked
        
        if (jp.getMenu() == JanelaPrincipal.MENU_UTILIZADOR)
        JOptionPane.showConfirmDialog(null, "Tem a certeza que quer apagar este utilizador?", "Apagar Utilizador", JOptionPane.YES_NO_OPTION);
        
        if (jp.getMenu() == JanelaPrincipal.MENU_ATIVIDADE)
        JOptionPane.showConfirmDialog(null, "Tem a certeza que quer apagar esta atividade?", "Apagar Atividade", JOptionPane.YES_NO_OPTION); 
        
        if (jp.getMenu() == JanelaPrincipal.MENU_EXERCICIO)
        JOptionPane.showConfirmDialog(null, "Tem a certeza que quer apagar este exercicio?", "Apagar Exercicio", JOptionPane.YES_NO_OPTION);
        
        if (jp.getMenu() == JanelaPrincipal.MENU_PLANO)
        JOptionPane.showConfirmDialog(null, "Tem a certeza que quer apagar este plano de treino?", "Apagar Plano Treino", JOptionPane.YES_NO_OPTION);   
        
        if (jp.getMenu() == JanelaPrincipal.MENU_ESPACO)
        JOptionPane.showConfirmDialog(null, "Tem a certeza que quer apagar este espaço fisico?", "Apagar Espaco Fisico", JOptionPane.YES_NO_OPTION);   
    }//GEN-LAST:event_apagarMouseClicked

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton apagar;
    private javax.swing.JButton bEdit;
    private javax.swing.JButton bNovo;
    public javax.swing.JLabel texto;
    // End of variables declaration//GEN-END:variables
}
